home *** CD-ROM | disk | FTP | other *** search
- Path: news.cern.ch!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: Jobs running under Unix.
- Date: 17 Apr 96 12:13:00 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.829743180@news.cern.ch>
- References: <829283553snz@tarik.demon.co.uk>
- NNTP-Posting-Host: ues5.cern.ch
- Mime-Version: 1.0
- Content-Type: text/plain; charset=US-ASCII
- Content-Transfer-Encoding: 7bit
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <829283553snz@tarik.demon.co.uk> Laurence Barea <larry@tarik.demon.co.uk> writes:
-
- >Is there anyone who knows how to tell whether a job is running under Unix
- >from within a C program.
- >
- >e.g. how do I stop a program from running more than once ?
-
- Since a non-Unix specific answer exists, I won't send you to
- comp.unix.programmer, where Unix-specific questions should be posted
- (but only after reading the comp.unix.questions FAQ).
-
- Use a lock file. If the lock file exists, issue an explanatory message
- and exit. Otherwise, create the lock file and go on.
-
- The method is far from perfect, but can be improved. For example,
- using a lock directory instead of a lock file will eliminate a possible
- race condition under Unix.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-